using MicroMsg.UI.Page;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class SelectStateItem : UserControl
	{
		public delegate void ListItemClick(object sender, object object_0);
		public static DependencyProperty ListItemProperty = DependencyProperty.Register("ItemObject", typeof(string), typeof(SelectStateItem), new PropertyMetadata(null, new PropertyChangedCallback(SelectStateItem.OnItemPropertyChanged)));
		private static SelectStateItem sSelectedItem = null;
		internal Button btnLayoutRoot;
		internal Grid LayoutRoot;
		internal DynamicTextBlock txtAreaName;
		private bool _contentLoaded;
		public event SelectStateItem.ListItemClick ItemClick;
		public string ItemObject
		{
			get
			{
				return (string)base.GetValue(SelectStateItem.ListItemProperty);
			}
			set
			{
				base.SetValue(SelectStateItem.ListItemProperty, value);
			}
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == SelectStateItem.ListItemProperty)
			{
				(dependencyObject_0 as SelectStateItem).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		public SelectStateItem()
		{
			this.InitializeComponent();
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_NewValue() is string)
			{
				string strState = dependencyPropertyChangedEventArgs_0.get_NewValue() as string;
				this.refresh(strState);
			}
		}
		private void refresh(string strState)
		{
			if (strState == null)
			{
				return;
			}
			this.txtAreaName.Text = strState;
			if (strState.Equals(SelectStatePage.sStrSelectedState))
			{
				this.txtAreaName.set_Foreground(R.theme.COMMON_BRUSH);
				if (SelectStateItem.sSelectedItem != null)
				{
					SelectStateItem.sSelectedItem.txtAreaName.set_Foreground(R.theme.LISTA_NAME_WORD_BRUSH);
				}
				SelectStateItem.sSelectedItem = this;
				return;
			}
			if (SelectStateItem.sSelectedItem == this)
			{
				SelectStateItem.sSelectedItem = null;
			}
			this.txtAreaName.set_Foreground(R.theme.LISTA_NAME_WORD_BRUSH);
		}
		private void btnLayoutRoot_Click(object sender, RoutedEventArgs e)
		{
			if (this.ItemClick != null)
			{
				SelectStatePage.sStrSelectedState = this.ItemObject.ToString();
				this.refresh(this.ItemObject);
				this.ItemClick(this, this.ItemObject);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Setting/SelectStateItem.xaml", 2));
			this.btnLayoutRoot = (Button)base.FindName("btnLayoutRoot");
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.txtAreaName = (DynamicTextBlock)base.FindName("txtAreaName");
		}
	}
}
